﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ParsecClient.Classes
{
    public class NestedCategory
    {
        public string Category { get; set; }
        public List<TimerDefinition> Timers { get; set; }
        public List<NestedCategory> Categories { get; set; }
        public NestedCategory()
        {
            Timers = new List<TimerDefinition>();
            Categories = new List<NestedCategory>();
        }
        public NestedCategory RecursiveFind(string s)
        {
            var rval = Categories.FirstOrDefault(x => string.CompareOrdinal(x.Category, s) == 0);
            if (rval != null)
                return rval;
            else
            {
                foreach (var c in Categories)
                {
                    rval = c.RecursiveFind(s);
                    if (rval != null)
                        return rval;
                }
            }
            return null;
        }
    }
}
